package pl.edu.amu.wmi.kino.visualjavafx.model.animation.transformations;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import pl.edu.amu.wmi.kino.visualjavafx.model.animation.interpolators.Interpolation;
import pl.edu.amu.wmi.kino.visualjavafx.model.objects.VisualObject;

// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
// #[regen=yes,id=DCE.C93486ED-7558-0412-666A-3962462B7F70]
// </editor-fold>
/**
 * Default values for all paramters are Double.NaN, set only those you really wish to change,
 * all unchanged parameters will NOT be generated in javafx code and it will work just fine
 * @author Admin
 */
public class Translation implements Transformation ,java.io.Serializable{

    // Code block for changeListeners support start
    protected PropertyChangeSupport propertySupport= new PropertyChangeSupport(this);
    @Override
    public void addPropertyChangeListener(PropertyChangeListener listener) {
        propertySupport.addPropertyChangeListener(listener);
    }
    @Override
    public void removePropertyChangeListener(PropertyChangeListener listener) {
        propertySupport.removePropertyChangeListener(listener);
    }
    // Code block for changeListeners support end

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.6C253C26-BBD4-216B-9B19-7ABE10CB54EF]
    // </editor-fold> 
    public Translation () {
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.99A61427-B0C1-EE3F-F589-068777A98C11]
    // </editor-fold> 
    @Override
    public Interpolation getInterpolation () {
        return this.myInterpolations[0];
    }

    @Override
    public Interpolation[] getInterpolations() {
        return this.myInterpolations;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.1A9E9D2D-31DC-B0F6-EFEE-61DD42255DC5]
    // </editor-fold> 
    @Override
    public void setInterpolation (Interpolation i) {
        Interpolation oldVal = this.myInterpolations[0];
        this.myInterpolations[0]=i;
        this.myInterpolations[1]=i;
        propertySupport.firePropertyChange( "Inerpolation" , oldVal, i);
    }


    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.460A8CCD-D273-6B7D-89D5-7989EAF60D2A]
    // </editor-fold> 
    @Override
    public VisualObject transform (double howMuch, VisualObject transformable,VisualObject orginalTransformedObject) {
        double posX=this.myInterpolations[0].getValue(howMuch,
                transformable.getHPos(), this.hDestination);
        double posY=this.myInterpolations[1].getValue(howMuch,
                transformable.getVPos(), this.vDestination);
        transformable.setHPos(posX);
        transformable.setVPos(posY);
        return transformable;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.2BB4C0A4-6E37-DE7A-AD3E-2D90303A0850]
    // </editor-fold> 
    public double getVDestination () {
        return this.vDestination;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.C4354553-0BD1-24F2-1837-5674C939C76D]
    // </editor-fold> 
    public void setVDestination (double val) {
        double oldVal = this.vDestination;
        this.vDestination=val;
        propertySupport.firePropertyChange( "VDestination" , oldVal, val);
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.5355CDCD-A2CA-8394-3625-A99206C8AB7C]
    // </editor-fold> 
    public double getHDestination () {
        return this.hDestination;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.27A863C4-84E0-7C2C-054C-284C71538F01]
    // </editor-fold> 
    public void setHDestination (double val) {
        double oldVal = this.hDestination;
        this.hDestination=val;
        propertySupport.firePropertyChange( "HDestination" , oldVal, val);
    }

    private Interpolation[] myInterpolations=new Interpolation[2];
    private double hDestination=Double.NaN;
    private double vDestination=Double.NaN;



}

